//package com.itheima.filter;
//
//import com.itheima.utilis.JwtUtils;
//import jakarta.servlet.*;
//import jakarta.servlet.annotation.WebFilter;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//
//import java.io.IOException;
//@WebFilter("/*")
//public class DemoFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//        Filter.super.init(filterConfig);
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
//        HttpServletRequest req = (HttpServletRequest) servletRequest;
//        HttpServletResponse rep = (HttpServletResponse) servletResponse;
//        String url = req.getRequestURL().toString();
//        if(url.contains("login")){
//            chain.doFilter(req,rep);
//        }
//        String token = req.getHeader("token");TODO
//        try {
//            JwtUtils.parseJWT(token);
//        }catch (Exception e){
//            e.printStackTrace();
//            rep.setStatus(401);
//        }
//        chain.doFilter(req,rep);
//
//    }
//
//    @Override
//    public void destroy() {
//        Filter.super.destroy();
//    }
//}
